function sum(arr){
    if(Array.isArray(arr)){
        var total =0;
        for(var i=0;i<arr.length;i++){
            var ele = arr[i];
            if(ele==null){
                continue;
            }
            if(isFinite(ele)){
                total+=ele;
            }else{
                throw new Error("数组的元素必须是有限数");
            }
        }
        console.log(total);
        
    }else{
        throw new Error("函数的参数必须是数组");
    }

}

sum([12,34]);

//没有重载
function func(){
    console.log("func函数");
    
}

function func(num){
    console.log("func num函数");
    
}

function func(n1,n2){
    console.log("func n1 n2 函数");
    
}
func();
func(3);
func(1,2);


console.log("-------------");
//数的阶乘
function factor(x){
    if(x<=1){
        return 1;
    }
    return x*factor(x-1);
}
console.log(factor(10));

function fa(x){
    if(x<=1) return 1;
    return x*arguments.callee(x-1);
}
console.log(fa(10));
var my = fa;
fa =null;
console.log(my(10));

